package cn.jbolt.ai.common.controller;


import cn.jbolt.ai.common.service.CommonService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 公共配置controller
 */
@Controller
@ResponseBody
@RequestMapping("/commonConfig")
@Tag(name = "公共配置controller")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @Operation(summary = "获取七牛的相关配置", description = "获取七牛的相关配置")
    @GetMapping("/getQiniu")
    public Result getQiniuConfig() {
        return commonService.getQiniuConfig();
    }

    @Operation(summary = "上传文件到七牛,并返回七牛地址", description = "上传文件到七牛,并返回七牛地址")
    @PostMapping("/uploadFileToQiniu")
    public Result uploadFileToQiniu(@RequestParam("file") MultipartFile file) {
        return commonService.uploadFileToQiniu(file);
    }

    @Operation(summary = "上传文件到本地,并返回本地地址", description = "上传文件到本地,并返回本地地址")
    @PostMapping("/uploadFileToLocal")
    public Result uploadFileToLocal(@RequestParam("file") MultipartFile file, String path) {
        return commonService.uploadFileToLocal(file,path);
    }




}
